package com.xuecx.userclient.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Author:xuecx
 * @CreateDate: 2019/7/27.
 * @QQ:1276162287
 * @Discription:
 */
@RestController
@RequestMapping("user")
public class UserController {

    private final RestTemplate restTemplate;

    @Autowired
    public UserController(RestTemplate restTemplate) {this.restTemplate = restTemplate;}

    @RequestMapping(value = "/get/{str}", method = RequestMethod.GET)
    public String echo(@PathVariable String str) {
        return restTemplate.getForObject("http://user-service/user/getUserName/" + str, String.class);
    }
}
